// 配置路由规则
import VueRouter from 'vue-router'
//引入组件
import firstPage from '../pages/firstPage'
import secondPage from '../pages/secondPage'
import CommodityList from '../pages/CommodityList'
import CommodityDetail from '../pages/CommodityDetail'
import CartList from '../pages/CartList'

// 创建并暴露一个路由器

export default new VueRouter ({
    routes:[
        {
            path:'/',
            component:firstPage,
        },
        {
            path:'/firstPage',
            component: firstPage,
        },
        {
            path:'/secondPage',
            component: secondPage,
        },
        {
            name:'CommodityList',
            path:'/CommodityList',
            component: CommodityList,
            props:true,
            children:[
                {
                    path:'CommodityDetail',
                    component:CommodityDetail,
                }
            ]
        },
        {
            name:'CommodityDetail',
            path:'/CommodityDetail/:id/:name/:price',   //params的传参方式
            //path:'/detail',
            component: CommodityDetail,
            props:true,  //true会把params的参数传给props
        },
        {
            path:'/CartList',
            component:CartList,
            props:true,   
        }
    ]
})
